package com.example.messageservice.controller;

import com.example.messageservice.service.MessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/messages")
public class MessageController {

    @Autowired
    private MessageService messageService;

    // 新增接口：给所有用户发送消息
    @PostMapping("/send-to-all")
    public void sendMessageToAllUsers(@RequestBody String message) {
        messageService.sendMessageToAllUsers(message);
    }
}